home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Univers Interactif 3
/
INTERACTIF.BIN
/
mac
/
Planete.net
/
Internet Confirmés_Vrac
/
NetAgent.sea
/
src
/
div_func.c
< prev
next >
Wrap
Text File
|
1992-06-15
|
3KB
|
114 lines
/*
This is an unsupported product. It was developed as part of a study at Ostfold
Regional College, Norway in the spring of 1992.
You use this software at your own risk. Neither the authors nor the Ostfold
Regional College nor any other person or organization except yourself is
responsible for any damage or loss of data derived from the use of this
software. You may distribute this software freely as long as it is in its
original form and all of its files are included. If you make any changes to any
part of this software or the files distributed with it, please state so and do
NOT distribute it under its original name.
*/
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <fcntl.h>
/*
-----------------------------------------------------------------------------
Function name: les_linje()
-----------------------------------------------------------------------------
Parameters: int fp File identifier.
char *s Buffer.
Return value: 0 on error
1 on success
Called by: reg_user(), nytt(), new_news(), do_user(), finn_stikkord()
Calls: none
Description: Reads a line from the file fp and puts the line into the
buffer pointed to by s.
-----------------------------------------------------------------------------
*/
int les_linje(fp, s)
int fp;
char *s;
{
char kar, *linje;
linje = s;
while((read(fp, &kar, 1)) >0) {
if(kar == '\n') {
*s = '\0';
if(*linje == '\0')
return(0);
else
return(1);
}
*s = kar;
s++;
}
return(0);
}
/*
-----------------------------------------------------------------------------
Function name: first_word()
-----------------------------------------------------------------------------
Parameters: char *s Pointer to a string.
Return value: none
Called by: finn_stikkord()
Calls: none
Description: Deletes the contains of a string except for the first word.
-----------------------------------------------------------------------------
*/
void first_word(s)
char *s;
{
while((*s != 32) && (*s != '\0'))
s++;
*s = '\0';
}
/*
-----------------------------------------------------------------------------
Function name: contains()
-----------------------------------------------------------------------------
Parameters: char *s Pointer to a string.
char *w Pointer to a string.
Return value: Returns 0 on failure
Returns 1 on success
Called by: do_user()
Calls: none
Description: Checks to see wether s cointains w.
-----------------------------------------------------------------------------
*/
int contains(s, w)
char *s;
char *w;
{
char *ord;
ord = w;
while( *s != '\0') {
if( *w == '\0') {
return(1);
}
if( toupper((int) *s) == toupper((int) *w) )
w++;
else
w = ord;
s++;
}
return(0);
}